/**
 * Created with IntelliJ IDEA.
 * User: ccr
 * Date: 13-6-4
 * Time: 上午9:57
 * To change this template use File | Settings | File Templates.
 */
$(function(){
    var grjkwin;
    $("#grjk_grid").datagrid({
        url:$.webPath() + "/cwgl/grjk/grjkList",
        fit:true,
        fitColumns:true,
        showFooter:true,
        pageNumber: 1,
        toolbar:"#toolbar_grjk",
        singleSelect:true,
        queryParams:{endDate:$("#grjk_endDate").val()},
        columns:[
            [{field:"gsJc",title:"公司",width:100,align: 'center'},
             {field:"gsjgJc",title:"部门",width:100,align: 'center'},
             {field:"ygXm",title:"职工姓名",width:100,align: 'center',formatter:function(value,row,index){
                 if(value == '合计'){
                     return '<span style="color:red;font-size:12pt">'+value+'</span>';
                 } else {
                     return value;
                 }
             }},
             {field:"ye",title:"余额",width:70,align:'right',formatter:function(value,row,index){
                if(row["ygXm"] == '合计'){
                    return '<span style="color:red;font-size:12pt">'+formatJe2(value,",",".")+'</span>';
                } else {
                    return '<a href="#" class="ye-linkbutton" style="color:red" ygId="'+row.ygId+'">'+formatJe2(value,",",".")+'</a>';
                }
            }}]
        ],
        onLoadSuccess:function(){
            $(".ye-linkbutton").linkbutton({plain:true}).unbind("click").bind("click",function(){
                grjkwin = $.window({
                    title:'个人借款详细',
                    width:750,
                    height:450,
                    cache:false,
                    url:$.webPath() + '/cwgl/grjk/grjk_mx?ygId='+$(this).attr("ygId"),
                    modal:true,
                    buttons:[]
                });
            });
            $(".datagrid-htable .datagrid-cell").css('text-align', 'center');
        }
    });
    $("#grjk_gsId").jgbmtree($("#grjk_gsjgId"), $("#grjk_ygId"), '', '');
    $("#grjk_search").click(function(){
        $("#grjk_grid").datagrid("load",{
            endDate:$("#grjk_endDate").combo("getValue")||'',
            gsId:$("#grjk_gsId").combobox("getValue")||'',
            gsjgId:$("#grjk_gsjgId").combobox("getValue")||'',
            ygId:$("#grjk_ygId").combobox("getValue")||''
        });
    });
});
